# 875 中等：爱吃香蕉的珂珂
import math


def minEatingSpeed(piles, h):
    piles.sort()
    l, r = 1, max(piles)
    while l < r:
        mid = l + ((r - l) >> 1)

        tol = 0
        for pile in piles:
            tol += math.ceil(1.0 * pile / mid)
        if tol <= h:
            r = mid
        else:
            l = mid + 1
        print(l, r, mid, tol)
    return l


print(minEatingSpeed([3, 11, 6, 7], 8))
print(minEatingSpeed([1, 2, 3, 11, 6, 7], 8))
